import ajax from '@/utils/request'
import { concatUrl } from '@/utils'

// 获取优惠券信息
export function getPromotion(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/order-promotion/cal-promotion', fields),
    data
  })
}

// 创建订单
export function createOrder(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/order/create', fields),
    data,
    method: 'POST'
  })
}

// 订单列表
export function getOrderList(data = {}, fields: string | object = { fields: '*,*.annualCardDetail' }) {
  console.log('data', data)
  return ajax({
    url: concatUrl('/v1/order/order/index', fields),
    data
  })
}


// 订单类型
export function getTypeConfig(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/order/business-status-config', fields),
    data
  })
}

// 订单详情
export function getOrderDetails(data = {}, fields: string | object = { fields: 'orderCy.checkModule,*,saleStore.*,orderFudeng.expectDateLabel,orderFudeng.consigneeAddress,orderFudeng.consigneeMobile,orderFudeng.expressNumber' }) {
  return ajax({
    url: concatUrl('/v1/order/order/view', fields),
    data
  })
}

/**
 *  获取车辆品牌
 */
export function getOrderExpress(data) {
  return ajax({
    method: 'GET',
    url: `${PUB_API_BASH_URL}/v1/express/query`,
    data
  })
}



// 去支付
export function payment(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/order/start-pay', fields),
    data,
    method: 'POST'
  })
}

// 获取支付方式
export function getPayMethod(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/order/pay-method-config', fields),
    data
  })
}

// 创建年卡订单
export function createAnnualOrder(data, fields: string | object = { fields: '*' }) {
  return ajax({
    // url: concatUrl('/v1/order/annual-card-order/create', fields),
    url: concatUrl('/v2/order/annual-card-order/create', fields),
    data,
    method: 'POST'
  })
}

// 取消订单
export function cancelOrder(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/order/cancel', fields),
    data,
    method: 'POST'
  })
}

// 退款申请
export function applyRefund(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/order-refund-apply/apply', fields),
    data,
    method: 'POST'
  })
}

// 取消退款申请
export function cancelRefund(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/order-refund-apply/cancel', fields),
    data,
    method: 'POST'
  })
}

// 退款申请详情
export function viewRefund(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/order-refund-apply/view', fields),
    data
  })
}

// 取消预约
export function cancelBooking(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/order/cancel-apply', fields),
    data,
    method: 'POST'
  })
}

// 去预约、修改预约
export function updateBooking(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/order/apply', fields),
    data,
    method: 'POST'
  })
}

// 获取接入商会员信息
export function vendorUserInfo(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/user/vendor-user/mine', fields),
    data
  })
}

// 推荐年卡套包商品
export function annualGoods(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    // url: concatUrl('/v1/annualCard/annual-card-recommend/annual-card-goods', fields),
    url: concatUrl('/v2/annualCard/annual-card-recommend/annual-card-goods', fields),
    data
  })
}

// 获取年卡有效期
export function annualValid(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/annualCard/annual-card-category/valid-day', fields),
    data
  })
}

// 门店信息
export function storeInfo(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/store/store-info', fields),
    data
  })
}

// 程序确认授权平台余额支付
export function ensurePlatformPay(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v2/order/order-receipt/ensure-message-for-platform-order', fields),
    data,
    method: 'POST'
  })
}

// 获取年卡的平台可售城市
export function getAnnualPlatformSaleCity(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v2/annualCard/annual-card-recommend/get-platform-sale-city', fields),
    data
  })
}

// 获取专题年卡的平台可售城市
export function getTopicAnnualPlatformSaleCity(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v2/store/get-optional-city-of-topic-annual-card', fields),
    data
  })
}

// 获取年卡的可下单门店列表
export function getAnnualStoreList(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v2/store/get-annual-card-list', fields),
    data
  })
}

// 判断年卡是否平台可售
export function getCheckIsCanSale(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v2/annualCard/annual-card-recommend/check-is-could-platform-sale', fields),
    data
  })
}


// 生成常悦检测报告
export function createNewEnergyCheckReport(data) {
  return ajax({
    url: concatUrl('/v1/check/create-new-energy-check-report',),
    data,
    method: 'POST'
  })
}

// 年卡创建退款申请
export function getOrderRefundApply(data = {}, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/order-refund-apply/detail', fields),
    data
  })
}
// 创建退款申请
export function createOrderRefund(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/order/order-refund-apply/create', fields),
    data,
    method: 'POST'
  })
}

// 创建新能源检测订单
export function createNReport(data = {}) {
  return ajax({
    url: concatUrl('/v1/check-report-cy/get-cy-res'),
    data
  })
}
